#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2020 Joyent, Inc.
# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
# Copyright (c) 2013 DEY Storage Systems, Inc. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2016 Toomas Soome <tsoome@me.com>
# Copyright 2018 Nexenta Systems, Inc.
# Copyright 2018 Gary Mills
# Copyright 2019 Peter Tribble
#

include ../Makefile.master

#
#	Note that the commands 'lp', and 'perl' are first in
#	the list, violating alphabetical order.  This is because they are very
#	long-running and should be given the most wall-clock time for a
#	parallel build.
#
#	Commands in the FIRST_SUBDIRS list are built before starting the build
#	of other commands.  Currently this includes only 'isaexec' and
#	'platexec'.  This is necessary because $(ROOT)/usr/lib/isaexec or
#	$(ROOT)/usr/lib/platexec must exist when some other commands are built
#	because their 'make install' creates a hard link to one of them.
#
#	Commands are listed one per line so that TeamWare can auto-merge most
#	changes.
#

FIRST_SUBDIRS=		\
	isaexec		\
	platexec

COMMON_SUBDIRS=		\
	allocate	\
	Adm		\
	abi		\
	adbgen		\
	asa		\
	attr		\
	audio		\
	auths		\
	autopush	\
	backup		\
	banner		\
	bart		\
	bdiff		\
	beadm		\
	boot		\
	bootparams	\
	busstat		\
	cat		\
	ccidadm		\
	cfgadm		\
	checkeq		\
	checknr		\
	chgrp		\
	chmod		\
	chown		\
	chroot		\
	clear		\
	clinfo		\
	cmd-crypto	\
	cmd-inet	\
	compress	\
	connstat	\
	consadm		\
	coreadm		\
	cp		\
	cpio		\
	cpc		\
	crypt		\
	ctfconvert	\
	ctfdiff		\
	ctfdump		\
	ctfmerge	\
	ctrun		\
	ctstat		\
	ctwatch		\
	datadm		\
	date		\
	dd		\
	demangle	\
	deroff		\
	devfsadm	\
	syseventd	\
	devctl		\
	devinfo		\
	devmgmt		\
	devprop		\
	dfs.cmds	\
	diffmk		\
	dircmp		\
	dis		\
	diskfltinj	\
	diskinfo	\
	dispadmin	\
	dladm		\
	dlstat		\
	dlutil		\
	dmesg		\
	dodatadm	\
	dtrace		\
	dumpadm		\
	dumpcs		\
	eeprom		\
	eject		\
	emul64ioctl	\
	eqn		\
	etdump		\
	exstr		\
	fcinfo		\
	fcoesvc		\
	fdetach		\
	fdformat	\
	fdisk		\
	ficl		\
	filesync	\
	file		\
	find		\
	flowadm		\
	flowstat	\
	fm		\
	fmthard		\
	fmtmsg		\
	format		\
	fs.d		\
	fstyp		\
	fuser		\
	fwflash		\
	gcore		\
	gencat		\
	genmsg		\
	getconf		\
	getdevpolicy	\
	getent		\
	getfacl		\
	getmajor	\
	getopt		\
	gettxt		\
	grep		\
	groups		\
	growfs		\
	halt		\
	head		\
	hostid		\
	hotplug		\
	hotplugd	\
	ibd_upgrade	\
	iconv		\
	id		\
	idmap		\
	init		\
	initpkg		\
	install.d	\
	intrstat	\
	ipcrm		\
	ipcs		\
	ipdadm		\
	ipf		\
	isainfo		\
	isalist		\
	iscsiadm	\
	iscsid		\
	iscsitsvc	\
	isns		\
	itadm		\
	kbd		\
	killall		\
	kvmstat		\
	last		\
	lgrpinfo	\
	line		\
	dlmgmtd		\
	listen		\
	loadkeys	\
	locale		\
	localedef	\
	lockstat	\
	locator		\
	lofiadm		\
	logadm		\
	logger		\
	logins		\
	ls		\
	luxadm		\
	mach		\
	makekey		\
	mdb		\
	mesg		\
	mkcsmapper	\
	mkdir		\
	mkesdb		\
	mkfile		\
	mkmsgs		\
	mktemp		\
	modload		\
	more		\
	mpathadm	\
	msgfmt		\
	msgid		\
	mvdir		\
	ndmpadm		\
	ndmpd		\
	ndmpstat	\
	netadm		\
	netfiles	\
	newform		\
	newgrp		\
	news		\
	newtask		\
	nlsadmin	\
	nsadmin		\
	nscd		\
	oamuser		\
	pack		\
	pagesize	\
	passmgmt	\
	pbind		\
	pcidb		\
	pcidr		\
	pcieadm		\
	pcieb		\
	pcitool		\
	pfexec		\
	pfexecd		\
	pginfo		\
	pgstat		\
	pgrep		\
	picl		\
	plimit		\
	power		\
	powertop	\
	ppgsz		\
	pg		\
	plockstat	\
	prctl		\
	priocntl	\
	profiles	\
	projadd		\
	projects	\
	prstat		\
	prtconf		\
	prtdiag		\
	prtvtoc		\
	ps		\
	psradm		\
	psrinfo		\
	psrset		\
	ptools		\
	raidctl		\
	raidz_test	\
	ramdiskadm	\
	rcap		\
	rcm_daemon	\
	rctladm		\
	refer		\
	regcmp		\
	renice		\
	roles		\
	rpcbind		\
	rpcgen		\
	rpcinfo		\
	rpcsvc		\
	runat		\
	saf		\
	sasinfo		\
	savecore	\
	sbdadm		\
	script		\
	scsi		\
	sdpadm		\
	setfacl		\
	setmnt		\
	setpgrp		\
	sgs		\
	smbios		\
	smserverd	\
	soelim		\
	srchtxt		\
	srptadm		\
	srptsvc		\
	stat		\
	stmfadm		\
	stmfproxy	\
	stmfsvc		\
	stmsboot	\
	streams		\
	strings		\
	svc		\
	swap		\
	sysdef		\
	syseventadm	\
	tabs		\
	tar		\
	tbl		\
	tcopy		\
	th_tools	\
	tip		\
	trapstat	\
	troff		\
	truss		\
	tsol		\
	ttymon		\
	tzreload	\
	uadmin		\
	uname		\
	unpack		\
	userattr	\
	users		\
	utmp_update	\
	utmpd		\
	valtools	\
	varpd		\
	vgrind		\
	vndadm		\
	vndstat		\
	vrrpadm		\
	vscan		\
	vt		\
	vtfontcvt	\
	w		\
	wall		\
	whodo		\
	xstr		\
	zdb		\
	zfs		\
	zhack		\
	zfs_ids_to_path	\
	zic		\
	zinject		\
	zlogin		\
	zoneadm		\
	zoneadmd	\
	zonecfg		\
	zonename	\
	zpool		\
	zlook		\
	zonestat	\
	zstreamdump	\
	zstream		\
	ztest

i386_SUBDIRS=		\
	acpi		\
	acpihpd		\
	addbadsec	\
	ahciem		\
	amdzen		\
	bhyve		\
	bhyvectl	\
	biosdev		\
	cxgbetool	\
	diskscan	\
	hyperv		\
	nvmeadm		\
	pptadm		\
	rdmsr		\
	rsrvrctl	\
	rtc		\
	ucodeadm	\
	xhci		\
	xvm

sparc_SUBDIRS=		\
	dcs		\
	device_remap	\
	drd		\
	fruadm		\
	ldmad		\
	oplhpd		\
	prtdscp		\
	prtfru		\
	scadm		\
	sckmd		\
	sf880drd	\
	virtinfo	\
	vntsd

#
# Commands that are messaged.  Note that 'lp' comes first
# (see previous comment about 'lp'.)
#
MSGSUBDIRS=		\
	abi		\
	allocate	\
	asa		\
	audio		\
	audit		\
	auditconfig	\
	auditd		\
	auditrecord	\
	auditset	\
	auths		\
	autopush	\
	backup		\
	banner		\
	bart		\
	beadm		\
	busstat		\
	cat		\
	cfgadm		\
	checkeq		\
	checknr		\
	chgrp		\
	chmod		\
	chown		\
	cmd-crypto	\
	cmd-inet	\
	compress	\
	connstat	\
	consadm		\
	coreadm		\
	cp		\
	cpio		\
	cpc		\
	ctrun		\
	ctstat		\
	ctwatch		\
	datadm		\
	date		\
	dcs		\
	dd		\
	deroff		\
	devfsadm	\
	dfs.cmds	\
	diffmk		\
	dladm		\
	dlstat		\
	dumpcs		\
	eject		\
	eqn		\
	fcinfo		\
	file		\
	filesync	\
	find		\
	flowadm		\
	flowstat	\
	fm		\
	fs.d		\
	fwflash		\
	genmsg		\
	getconf		\
	getent		\
	gettxt		\
	grep		\
	halt		\
	head		\
	hotplug		\
	id		\
	idmap		\
	isaexec		\
	iscsiadm	\
	iscsid		\
	isns		\
	itadm		\
	kbd		\
	last		\
	lgrpinfo	\
	locale		\
	lofiadm		\
	logadm		\
	logger		\
	logins		\
	ls		\
	luxadm		\
	mesg		\
	mkdir		\
	mktemp		\
	more		\
	mpathadm	\
	msgfmt		\
	ndmpadm		\
	ndmpstat	\
	newgrp		\
	newtask		\
	pack		\
	passmgmt	\
	pfexec		\
	pg		\
	pgrep		\
	picl            \
	power		\
	praudit		\
	profiles	\
	projadd		\
	projects	\
	prstat		\
	prtdiag		\
	ps		\
	psrinfo		\
	ptools		\
	raidctl		\
	ramdiskadm	\
	rcap		\
	rcm_daemon	\
	refer		\
	regcmp		\
	renice		\
	roles		\
	sasinfo		\
	sbdadm		\
	scadm		\
	script		\
	scsi		\
	sdpadm		\
	sgs		\
	srptadm		\
	stat		\
	stmfadm		\
	stmsboot	\
	strings		\
	svc		\
	swap		\
	syseventadm	\
	syseventd	\
	tabs		\
	tar		\
	tbl		\
	troff		\
	tsol		\
	ttymon		\
	tzreload	\
	uname		\
	unpack		\
	userattr	\
	valtools	\
	vgrind		\
	vrrpadm		\
	vscan		\
	w		\
	whodo		\
	zfs		\
	zlogin		\
	zoneadm		\
	zoneadmd	\
	zonecfg		\
	zonename	\
	zpool		\
	zonestat

sparc_MSGSUBDIRS=	\
	fruadm		\
	prtdscp		\
	prtfru		\
	virtinfo	\
	vntsd

i386_MSGSUBDIRS=	\
	rdmsr		\
	ucodeadm

#
# commands that use dcgettext for localized time, LC_TIME
#
DCSUBDIRS=		\
	cfgadm		\
	ls		\
	ps		\
	tar		\
	w		\
	whodo

#
# commands that belong only to audit.
#
AUDITSUBDIRS=		\
	amt		\
	audit		\
	audit_warn	\
	auditconfig	\
	auditd		\
	auditrecord	\
	auditreduce	\
	auditset	\
	auditstat	\
	praudit

#
# commands not owned by the systems group
#
BWOSDIRS=

$(ENABLE_EXT)include $(EXT_SRC)/illumos/cmd/Makefile

all :=		TARGET = all
install :=	TARGET = install
clean :=	TARGET = clean
clobber :=	TARGET = clobber
_msg :=		TARGET = _msg
_dc :=		TARGET = _dc

.KEEP_STATE:

SUBDIRS = $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)

.PARALLEL:	$(SUBDIRS) $(MSGSUBDIRS) $(AUDITSUBDIRS)

all install clean clobber: $(FIRST_SUBDIRS) .WAIT $(SUBDIRS) \
	$(AUDITSUBDIRS)

#
# Manifests cannot be checked in parallel, because we are using
# the global repository that is in $(SRC)/cmd/svc/seed/global.db.
# For this reason, to avoid .PARALLEL and .NO_PARALLEL conflicts,
# we spawn off a sub-make to perform the non-parallel 'make check'
#
check:
	$(MAKE) -f Makefile.check check

#
# The .WAIT directive works around an apparent bug in parallel make.
# Evidently make was getting the target _msg vs. _dc confused under
# some level of parallelization, causing some of the _dc objects
# not to be built.
#
_msg: $(MSGSUBDIRS) $($(MACH)_MSGSUBDIRS) .WAIT _dc

_dc: $(DCSUBDIRS)

#
# Dependencies
#
fs.d:	fstyp
#mdb:	terminfo

$(FIRST_SUBDIRS) $(SUBDIRS) $(AUDITSUBDIRS): FRC
		cd $@; pwd; $(MAKE) $(TARGET)

FRC:
